#include <bits/stdc++.h>
using namespace std;
char buf[(int)5e7], *fs = buf;
inline int gn() { 
    int k = 0;
    char c = *fs++;
    for (; !isdigit(c); c = *fs++);
    for (; isdigit(c); c = *fs++) k = k * 10 + c - '0';
    return k;
}
const int maxn = 2e6 + 3;
int dp[maxn][2], a[maxn], n, k;
int main() { 
    freopen("wave.in", "r", stdin);
    freopen("wave.out", "w", stdout);
    fread(buf, 1, (int)5e7, stdin);
    n = gn(), k = gn();
    for (int i = 1; i <= n; i++) 
        a[i] = gn();
    for (int i = 2; i <= n; i++) { 
        int mxdp = 0, midp = 0;
        for (int j = i - 1; j; j--) { 
            if (a[j] + k <= a[i] and dp[j][0] > mxdp) 
                mxdp = dp[j][0];
            if (a[j] >= a[i] + k and dp[j][1] > midp)
                midp = dp[j][1];
        }
        if(mxdp!=0) 
            dp[i][1] = mxdp + 1;
        dp[i][0] = midp + 1;
    }
    printf("%d\n", max(dp[n][1], dp[n][0]));
}
